/*
 * Project: purple
 * 
 * File Created at 2018年12月7日
 * 
 */
package xin.mydreams.purple.init;

import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.http.HttpRequestDecoder;
import io.netty.handler.codec.http.HttpResponseEncoder;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
import xin.mydreams.purple.handle.PurpleHttpDispatcherHandle;

/**
 * 初始化netty的HTTP请求
 * @Type CicadaInitializer.java 
 * @email guzehao@mydreams.xin
 * @author 谷泽昊
 * @blog https://www.mydreams.xin
 * @date 2018年12月7日 下午9:06:48
 * @version 
 */
public class CicadaInitializer extends ChannelInitializer<Channel> {

    @Override
    public void initChannel(Channel ch) throws Exception {
        ch.pipeline()
                .addLast(new HttpRequestDecoder())
                .addLast(new HttpResponseEncoder())
                .addLast(new ChunkedWriteHandler())
                .addLast(new PurpleHttpDispatcherHandle())
                .addLast("log", new LoggingHandler(LogLevel.INFO));
    }
}


/**
 *
 * Revision history
 * -------------------------------------------------------------------------
 * 
 * Date Author Note
 * -------------------------------------------------------------------------
 * 2018年12月7日 谷泽昊 creat
 */